<template>
  <div class="recommendationContainer">
    <a-carousel arrows autoplay>
      <div
          slot="prevArrow"
          slot-scope="props"
          class="custom-slick-arrow"
          style="left: 10px;zIndex: 1"
      >
        <a-icon type="left-circle"/>
      </div>
      <div slot="nextArrow" slot-scope="props" class="custom-slick-arrow" style="right: 10px">
        <a-icon type="right-circle"/>
      </div>
      <div><img width="553" height="215"
                src="http://p1.music.126.net/bCgWA2kpLacZrMgRfWPPPA==/109951167025770777.jpg?imageView&quality=89">
      </div>
      <div><img width="553" height="215"
                src="http://p1.music.126.net/bCgWA2kpLacZrMgRfWPPPA==/109951167025770777.jpg?imageView&quality=89">
      </div>
      <div><img width="553" height="215"
                src="http://p1.music.126.net/bCgWA2kpLacZrMgRfWPPPA==/109951167025770777.jpg?imageView&quality=89">
      </div>
      <div><img width="553" height="215"
                src="http://p1.music.126.net/bCgWA2kpLacZrMgRfWPPPA==/109951167025770777.jpg?imageView&quality=89">
      </div>
      <div><img width="553" height="215"
                src="http://p1.music.126.net/bCgWA2kpLacZrMgRfWPPPA==/109951167025770777.jpg?imageView&quality=89">
      </div>

    </a-carousel>
    <br>
    <a-row :gutter="[16,16]">
      <a-col :span="24" class="recommendationMusicListTitle">推荐歌单 ></a-col>
      <!--每日推荐-->
      <a-col :span="6" class="recommendationMusicContainer" @click="musicListDetail(0)">
        <div class="recommendationMusic">
          <img src="https://p1.music.126.net/S_xgO2YdFM-eqgUAbK9ZXg==/109951166376672765.jpg" width="124" height="124">
        </div>
        <div>每日歌曲推荐</div>
      </a-col>
      <a-col :span="6" v-for="(record) in musicListData" class="recommendationMusicContainer"
             @click="musicListDetail(record.id)">
        <div class="recommendationMusic">
          <img :src="record.picUrl" width="124" height="124">
        </div>
        <div class="recommendationMusicName">{{ record.name }}</div>
      </a-col>
    </a-row>
  </div>
</template>

<script>
import {recommendResource,personalized} from "@/api/api";
import Vue from "vue";
import {USER_COOKIE} from "@/store/mutation-types";

export default {
  name: "Recommendation",
  data() {
    return {
      musicListData: []
    }
  },
  mounted() {
    this.getRecommendationMusicList();
  },
  methods: {
    getRecommendationMusicList() {
      let _this = this;
      // 获取每日推荐歌单 登录后的
      let params = {
        'limit': 11,
        "cookie": Vue.ls.get(USER_COOKIE)
      }
      // 登录则请求该接口
      personalized(params).then(res=>{
        _this.musicListData = res.result;
        if (_this.musicListData.length > 11) {
          _this.musicListData.length = 11; // 只取11个
        }
      })
    },
    musicListDetail(musicListId) {
      if (musicListId  === 0){ // 每日推荐歌单
        // 跳转到歌单详情
        this.$router.push({
          path: "/dailyRecommendation",
        })
      }else{
        // 跳转到歌单详情
        this.$router.push({
          path: "/playListDetail",
          query: {
            musicListId: musicListId
          }
        })
      }
    }
  }
}
</script>

<style scoped>
.recommendationContainer {
  padding: 1rem;
  height: auto;
  background-color: white;
}

/*推荐歌单*/
.recommendationMusicContainer {
  /*border: 1px red solid;*/
  height: 11rem;
  padding: 1rem;
  position: relative;
  cursor: pointer;
}

.recommendationMusicListTitle {
  text-align: left;
  font-size: 16px;
  font-weight: bold;
  color: black;
}

.recommendationMusic {
  /*border: 1px red solid;*/
  height: 8rem;
  color: black;
}

.recommendationMusic > img {
  /*display: inline-block;*/
  border-radius: 0.4rem;
}

.recommendationMusicName {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.recommendationMusicList {
  width: 100%;
  border: 1px red solid;
}


/* 轮播图 */
.ant-carousel >>> .slick-slide {
  text-align: center;
  height: 215px;
  line-height: 215px;
  background: #364d79;
  overflow: hidden;
}

.ant-carousel >>> .custom-slick-arrow {
  width: 25px;
  height: 25px;
  font-size: 25px;
  color: #fff;
  background-color: rgba(31, 45, 61, 0.11);
  opacity: 0.3;
}

.ant-carousel >>> .custom-slick-arrow:before {
  display: none;
}

.ant-carousel >>> .custom-slick-arrow:hover {
  opacity: 0.5;
}

.ant-carousel >>> .slick-slide h3 {
  color: #fff;
}

/* 轮播图 */

</style>
